import { TransferReqVO } from '@/api/crm/permission'
import contractApi from '@/api/declaration/crm/contractApi'
import httpRequest from '@/config/axios/httpRequest'
import { CrmContractModel } from '@/models/crm/CrmContractModel'



// 查询 CRM 合同列表
export const getContractPage = async (params) => {
  return await httpRequest.get<CrmContractModel[]>(contractApi.GetContractPage, { params })
}

// 查询 CRM 联系人列表，基于指定客户
export const getContractPageByCustomer = async (params: any) => {
  return await httpRequest.get(contractApi.GetContractPageByCustomer, { params })
}

// 查询 CRM 联系人列表，基于指定商机
export const getContractPageByBusiness = async (params: any) => {
  return await httpRequest.get(contractApi.GetContractPageByBusiness, { params })
}

// 查询 CRM 合同详情
export const getContract = async (id: number) => {
  return await httpRequest.get(contractApi.GetContract, { params: { id } })
}

// 查询 CRM 合同下拉列表
export const getContractSimpleList = async (customerId: number) => {
  return await httpRequest.get(contractApi.GetContractSimpleList, { params: { customerId } })
}

// 新增 CRM 合同
export const createContract = async (data: CrmContractModel) => {
  return await httpRequest.post(contractApi.CreateContract, data)
}

// 修改 CRM 合同
export const updateContract = async (data: CrmContractModel) => {
  return await httpRequest.put(contractApi.UpdateContract, data)
}

// 删除 CRM 合同
export const deleteContract = async (id: number) => {
  return await httpRequest.delete(contractApi.DeleteContract, { params: { id } })
}

// 导出 CRM 合同 Excel
export const exportContract = async (params) => {
  return await httpRequest.download(contractApi.ExportContract, params)
}

// 提交审核
export const submitContract = async (id: number) => {
  return await httpRequest.put(contractApi.SubmitContract, { id })
}

// 合同转移
export const transferContract = async (data: TransferReqVO) => {
  return await httpRequest.put(contractApi.TransferContract, data)
}

// 获得待审核合同数量
export const getAuditContractCount = async () => {
  return await httpRequest.get(contractApi.GetAuditContractCount)
}

// 获得即将到期（提醒）的合同数量
export const getRemindContractCount = async () => {
  return await httpRequest.get(contractApi.GetRemindContractCount)
}
